package top.laoshuzi.rpi3

import lib.bcm2835.*

class Led {

    private val pin = RPI_GPIO_P1_11.toUByte()
    private var bcm2835Manager = Bcm2835Manager.INSTANCE

    init {
        bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP.toUByte())
    }

    fun close() {
        bcm2835Manager.close()
    }

    fun blink(count: Int) {
        var temp = count
        while (temp-- >= 0) {

            println("高")
            bcm2835_gpio_write(pin, HIGH)
            bcm2835_delay(1000)

            println("低")
            bcm2835_gpio_write(pin, LOW)
            bcm2835_delay(1000)
        }

    }

}